home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8336 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  853 b 

  1. Path: news.orst.edu!butch
  2. From: preddym@ucs.orst.edu (M Preddy)
  3. Newsgroups: comp.lang.c++
  4. Subject: help with cin.getline()
  5. Date: Fri, 16 Feb 96 21:42:44 GMT
  6. Organization: Oregon State University
  7. Message-ID: <4g2tiv$gc0@news.orst.edu>
  8. NNTP-Posting-Host: butch.physics.orst.edu
  9. X-Newsreader: News Xpress Version 1.0 Beta #4
  10.  
  11. Please forgive my newbie naivity, but I'm having trouble with 
  12. cin.getline() under MSVC++ 4.0.  Why does the following snipit,
  13.  
  14.  
  15.     char cd_query[4];    
  16.     do
  17.         {
  18.             cout << "Constant Cd (y/n)? ";
  19.             cin.getline(cd_query,4);
  20.         } while (cd_query[0] !='n' && cd_query[0] != 'y');
  21.  
  22.  
  23. Produce the following output before stopping to wait for user input:
  24.  
  25.     Constant Cd (y/n)? Constant Cd (y/n)?
  26.  
  27. The do-loop executes once, without stopping for input until the second 
  28. pass.  This is obviously not what I want.  Thank you for your help.
  29.  
  30. Mark
  31.